<?php

namespace UU\Suite;


use Hyperf\Utils\Str;
use UU\Suite\DingTalk\Application;

/**
 * Class Suite
 * @method static Application           DingTalk(array $config)
 * @package UU\Suite
 */
class Suite
{
    public static function make(string $name, array $config)
    {
        $namespace = Str::studly($name);
        $application = "\\UU\Suite\\{$namespace}\\Application";
        #如果存在di make就用管理依赖
//        if (function_exists('di')) {
//            return di()-;
//        }
        return new $application($config);
    }

    /**
     * @param $data
     * @param array $config
     * @return Application
     * @throws \Exception
     */
    public static function app(array $config = [])
    {
        $type = $config['driver'] ?? '';
        if (!in_array($type, ['DingTalk', 'OpenWork', 'FeiShu'])) {
            throw new \Exception('暂不支持该驱动，目前只支持DingTalk, OpenWork, FeiShu！');
        }
        return self::make($type, $config);
    }

}